/**
 * 
 */
package com.furschina.struts2;

import org.springframework.security.core.context.SecurityContextHolder;

import cn.wooshai.core.struts2.WooshaiAction;

import com.furschina.model.User;
import com.furschina.vo.LoginUser;

/**
 * @author iday
 *
 */
public abstract class BaseAction extends WooshaiAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5541044211580468399L;

	public LoginUser getLoginUser() {
		Object o = SecurityContextHolder.getContext().getAuthentication()
				.getPrincipal();
		if (o instanceof LoginUser) {
			LoginUser user = (LoginUser) o;
			return user;
		}
		return null;
	}
	
	public String getLoginName(){
		if(null==this.getLoginUser()) return null;
		return this.getLoginUser().getUsername();
	}
	
	public User getUser() {
		return this.getLoginUser().getUser();
	}
}
